package sourceagile.server.utilities;

public class FileNameGenerator {

	public static String getFileName(String filePath) {

		String[] filePathArray = filePath.split("/");

		String fileName = filePathArray[filePathArray.length - 1];

		return fileName;
	}

	public static String getFilePath(String fileFullName, String fileName) {

		String[] filePathArray = fileFullName.split("/");

		if (filePathArray.length > 1) {

			String filePath = fileFullName.substring(0, fileFullName.length()
					- fileName.length() - 1);

			return filePath;

		} else {

			return "";
		}
	}

	public static String compactName(String name) {

		return compactName(name, false);
	}

	public static String compactName(String name, boolean isFolder) {

		String[] words = (name.trim()).split(" ");

		String compressedFileName = "";

		for (int i = 0; i < words.length; i++) {

			String word = words[i];

			if (isFolder && i == 0) {

				word = (word.substring(0, 1)).toLowerCase() + word.substring(1);

			} else {

				word = (word.substring(0, 1)).toUpperCase() + word.substring(1);
			}

			compressedFileName += word;
		}

		return compressedFileName;
	}

}
